<!--  -->
<template>
  <div>
    <p>考核要求：严格执行学生请销假登记制度（5分）&emsp;&emsp;&emsp;&emsp;考核方式：学工系统记录，未能按规定完成1次扣1分。</p>
    <div style="display: flex; align-items: center;">
      <div>
        辅导员自评分：{{ form.kpiFillingBusinessWorksList[0].stuLeaveMaterialsScoring || "没有填写" }}
      </div>
      <div style="display: flex; align-items: center;margin-left: 50px;" v-if="isShow">
        <div style="min-width: 70px;color: red;">调整分数：</div>
        <el-input-number v-model="form.kpiFillingBusinessWorksList[0].stuLeaveMaterialsScoring" :min="0" :max="5" label="调整分数" size="mini" style="width: 100%;"></el-input-number>
        <!-- <el-input placeholder="请输入自评分" v-model="form.kpiFillingBusinessWorksList[0].stuLeaveMaterialsScoring" clearable
          size="mini">
        </el-input> -->
      </div>
    </div>
    <p>考核要求：认真指导学生完成各项材料填报工作（10分）&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;考核方式：学务办、学工各项工作记录，未能按规定完成1次扣1分。</p>
    <div style="display: flex; align-items: center;">
      <!-- 辅导员自评分：{{ form.kpiFillingBusinessWorksList[0].stuFillingMaterialsScoring || "没有填写" }} -->
      <div>
        辅导员自评分：{{ form.kpiFillingBusinessWorksList[0].stuFillingMaterialsScoring || "没有填写" }}
      </div>
      <div style="display: flex; align-items: center;margin-left: 50px;" v-if="isShow">
        <div style="min-width: 70px;color: red;">调整分数：</div>
        <el-input-number v-model="form.kpiFillingBusinessWorksList[0].stuFillingMaterialsScoring" :min="0" :max="10" label="调整分数" size="mini" style="width: 100%;"></el-input-number>
        <!-- <el-input placeholder="请输入自评分" v-model="form.kpiFillingBusinessWorksList[0].stuFillingMaterialsScoring" clearable
          size="mini">
        </el-input> -->
      </div>
    </div>
    <p>考核要求:按时按质完成学生基础数据上报工作（10分）&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;考核方式：学务办、学工各项工作记录，未能按规定完成1次扣1分。</p>
    <div style="display: flex; align-items: center;">
      <!-- 辅导员自评分：{{ form.kpiFillingBusinessWorksList[0].stuBasicDataScoring || "没有填写" }} -->
      <div>
        辅导员自评分：{{ form.kpiFillingBusinessWorksList[0].stuBasicDataScoring || "没有填写" }}
      </div>
      <div style="display: flex; align-items: center;margin-left: 50px;" v-if="isShow">
        <div style="min-width: 70px;color: red;">调整分数：</div>
        <el-input-number v-model="form.kpiFillingBusinessWorksList[0].stuBasicDataScoring" :min="0" :max="10" label="调整分数" size="mini" style="width: 100%;"></el-input-number>
        <!-- <el-input placeholder="请输入自评分" v-model="form.kpiFillingBusinessWorksList[0].stuBasicDataScoring" clearable
          size="mini">
        </el-input> -->
      </div>
    </div>
    <p>考核要求：按规定完成学生违纪处分材料（10分）&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;考核方式：学务办、学工各项工作记录，未能按规定完成1次扣2分。</p>
    <div style="display: flex; align-items: center;">
      <!-- 辅导员自评分：{{ form.kpiFillingBusinessWorksList[0].stuDisciplinaryViolationScoring || "没有填写" }} -->
      <div>
        辅导员自评分：{{ form.kpiFillingBusinessWorksList[0].stuDisciplinaryViolationScoring || "没有填写" }}
      </div>
      <div style="display: flex; align-items: center;margin-left: 50px;" v-if="isShow">
        <div style="min-width: 70px;color: red;">调整分数：</div>
        <el-input-number v-model="form.kpiFillingBusinessWorksList[0].stuDisciplinaryViolationScoring" :min="0" :max="10" label="调整分数" size="mini" style="width: 100%;"></el-input-number>
        <!-- <el-input placeholder="请输入自评分" v-model="form.kpiFillingBusinessWorksList[0].stuDisciplinaryViolationScoring" clearable
          size="mini">
        </el-input> -->
      </div>
    </div>
    <p>考核要求：按程序要求处理突发事件（10分）&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;考核方式：学务办、学工各项工作记录，未能按规定完成不得分。</p>
    <div style="display: flex; align-items: center;">
      <!-- 辅导员自评分：{{ form.kpiFillingBusinessWorksList[0].handleEventsScoring || "没有填写" }} -->
      <div>
        辅导员自评分：{{ form.kpiFillingBusinessWorksList[0].handleEventsScoring || "没有填写" }}
      </div>
      <div style="display: flex; align-items: center;margin-left: 50px;" v-if="isShow">
        <div style="min-width: 70px;color: red;">调整分数：</div>
        <el-input-number v-model="form.kpiFillingBusinessWorksList[0].handleEventsScoring" :min="0" :max="10" label="调整分数" size="mini" style="width: 100%;"></el-input-number>
        <!-- <el-input placeholder="请输入自评分" v-model="form.kpiFillingBusinessWorksList[0].handleEventsScoring" clearable
          size="mini">
        </el-input> -->
      </div>
    </div>
    <div class="button" v-if="form.kpiFillingBusinessWorksList[0].hasOwnProperty('id') && !(form.auditStatus === 1 && form.roleAudit === 4)">
      <el-button type="primary" v-show="isShow" @click="save">保 存</el-button>
      <el-button type="warning" @click="switchIsShow" v-if="!roleGroup.includes('辅导员') && audit">修 改</el-button>
    </div>
  </div>
</template>

<script>
import { getKpiFillingBusinessWork, updateKpiFillingBusinessWork } from "@/api/teacher/kpiFillingBusinessWork";
export default {
  props: {
    form: {
      type: Object,
      default: []
    },
    roleGroup: {
      type: String,
      default: ""
    },
    audit: {
      type: Boolean,
      default: true
    }
  },
  watch: {
    "form.kpiFillingBusinessWorksList": {
      immediate: true,
      handler() {
        if (this.form.kpiFillingBusinessWorksList.length === 0) {
          this.form.kpiFillingBusinessWorksList[0] = {
            handleEventsScoring: 0,
            stuBasicDataScoring: 0,
            stuDisciplinaryViolationScoring: 0,
            stuFillingMaterialsScoring: 0,
            stuLeaveMaterialsScoring: 0
          }
        }
      }
    }
  },
  data() {
    return {
      isShow: false
    }
  },
  methods: {
    switchIsShow() {
      this.isShow = !this.isShow
    },
    save() {
      this.$modal.loading('正在努力加载中，请稍等。。。')
      updateKpiFillingBusinessWork(this.form.kpiFillingBusinessWorksList[0]).then(response => {
        // this.$modal.msgSuccess("修改成功");
        getKpiFillingBusinessWork(this.form.kpiFillingBusinessWorksList[0].id).then(response => {
          this.form.kpiFillingBusinessWorksList[0].handleEventsScoring = response.data.handleEventsScoring,
          this.form.kpiFillingBusinessWorksList[0].stuBasicDataScoring = response.data.stuBasicDataScoring,
          this.form.kpiFillingBusinessWorksList[0].stuDisciplinaryViolationScoring = response.data.stuDisciplinaryViolationScoring,
          this.form.kpiFillingBusinessWorksList[0].stuFillingMaterialsScoring = response.data.stuFillingMaterialsScoring,
          this.form.kpiFillingBusinessWorksList[0].stuLeaveMaterialsScoring = response.data.stuLeaveMaterialsScoring,
          this.$modal.msgSuccess("修改成功");
          this.switchIsShow()
          this.$modal.closeLoading()
        });
      });
    }
  },
  // 生命周期 - 创建完成（访问当前this实例）
  created() {

  },
  // 生命周期 - 挂载完成（访问DOM元素）
  mounted() {

  },
  // 离开当前页面时执行代码
  destroyed() {

  }
}
</script>
<style scoped>
/* @import url(); 引入css类 */
.button {
  margin-top: 20px;
  position: sticky;
  bottom: 0;
  background-color: white;
  z-index: 100;
  text-align: right;
  padding: 10px;
}
</style>
